using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JHVideo
{
    public class VideoFactory
    {
        private VideoFactory() { }
        private static IVideo mVideo = null;
        private static object mlocker = new object();

        /// <summary>
        /// 创建监控对象
        /// </summary>
        /// <param name="VideoType"></param>
        /// <returns></returns>
        public static IVideo CreateVideo(VideoType type)
        {
            if(mVideo == null)
            {
                lock (mlocker)
                {
                    if(mVideo == null)
                    {
                        if (type == VideoType.HK)
                        {
                            mVideo = new HkVideo();
                        }
                        else if(type ==VideoType.DH)
                        {
                            mVideo = new DHVideo();
                        }
                        else
                        {
                            return null;
                        }
                    }
                }
            }

            return mVideo;
        }

        /// <summary>
        /// 释放监控对象
        /// </summary>
        public static  void DestoryVideo()
        {
            if (mVideo != null)
            {
                mVideo.Close();
                mVideo = null;
            }
        }
    }
}


